package com.bbx.taxi.client.Activity.Order;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.R.integer;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.database.Cursor;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.test.TouchUtils;
import android.text.Editable;
import android.text.Html;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.style.ImageSpan;
import android.util.Log;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.view.ViewGroup.LayoutParams;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.PopupWindow.OnDismissListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.GridView;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RatingBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import butterknife.InjectView;

import com.baidu.mapapi.map.BaiduMap;
import com.baidu.mapapi.map.BitmapDescriptor;
import com.baidu.mapapi.map.BitmapDescriptorFactory;
import com.baidu.mapapi.map.InfoWindow;
import com.baidu.mapapi.map.MapStatus;
import com.baidu.mapapi.map.MapStatusUpdate;
import com.baidu.mapapi.map.MapStatusUpdateFactory;
import com.baidu.mapapi.map.MapView;
import com.baidu.mapapi.map.Marker;
import com.baidu.mapapi.map.MarkerOptions;
import com.baidu.mapapi.map.OverlayOptions;
import com.baidu.mapapi.model.LatLng;
import com.baidu.mapapi.utils.DistanceUtil;
import com.bbx.androidapi.util.ToastUtil;
import com.bbx.api.gclient.GMsg;
import com.bbx.api.sdk.SDK;
import com.bbx.api.sdk.model.comm.returns.line.To_Cities;
import com.bbx.api.sdk.model.official.passanger.Offciail_CancelPriceBuild;
import com.bbx.api.sdk.model.official.passanger.Officail_CancelBuild;
import com.bbx.api.sdk.model.official.passanger.Officail_PriceBuild;
import com.bbx.api.sdk.model.official.passanger.Official_OrderListBuild;
import com.bbx.api.sdk.model.official.passanger.Return.Officail_Price;
import com.bbx.api.sdk.model.official.passanger.Return.OrderList.OfficialOrderList;
import com.bbx.api.sdk.model.official.passanger.Return.OrderList.VehicleInfo;
import com.bbx.api.sdk.model.passanger.CancelOrder;
import com.bbx.api.sdk.model.passanger.Return.Position;
import com.bbx.api.sdk.model.passanger.Return.Jmsg.Msgs;
import com.bbx.api.sdk.net.base.JsonBuild;
import com.bbx.api.sdk.net.official.passanger.Officail_CancelNet;
import com.bbx.api.sdk.net.passeger.conn.CancelOrderNet;
import com.bbx.api.util.LogUtils;
import com.bbx.taxi.client.Task.BaseAsyncTask;
import com.bbx.taxi.client.Task.MyCancelOrderTask.OnCancelOrderListener;
import com.bbx.taxi.client.Task.MyCancelPriceTask.OnCancelPriceListener;
import com.bbx.taxi.client.Task.MyCancelOrderTask;
import com.bbx.taxi.client.Task.MyOrderTask;
import com.bbx.taxi.client.Task.MyCancelPriceTask;
import com.bbx.taxi.client.Task.MyStarTask;
import com.bbx.taxi.client.Task.MyStarTask.OnStarListener;
import com.bbx.taxi.client.MyApplication;
import com.bbx.taxi.official.R;
import com.bbx.taxi.client.Activity.MainActivity;
import com.bbx.taxi.client.Activity.Base.BaseBBXActivity;
import com.bbx.taxi.client.Activity.Base.BaseMapBBXActivity;
import com.bbx.taxi.client.Activity.Menu.MyOrderActivity;
import com.bbx.taxi.client.Adapter.Chat.ChatMessageListAdapter;
import com.bbx.taxi.client.Adapter.Chat.ExpressionImageAdapter;
import com.bbx.taxi.client.Adapter.Chat.MyFacePagerAdapter;
import com.bbx.taxi.client.Adapter.Page.MyPagerAdapter;
import com.bbx.taxi.client.Bean.ChatMessage;
import com.bbx.taxi.client.Bean.Expression;
import com.bbx.taxi.client.Bean.Value;
import com.bbx.taxi.client.Bean.Attribute.ChangeAttribute;
import com.bbx.taxi.client.Bean.Attribute.MainAttribute;
import com.bbx.taxi.client.Bean.Extra.ExamineMsg;
import com.bbx.taxi.client.Bean.Extra.MainMsg;
import com.bbx.taxi.client.Bean.Extra.OrderMsg;
import com.bbx.taxi.client.Bean.Message.MyMesssage;
import com.bbx.taxi.client.Bean.Message.Online;
import com.bbx.taxi.client.DB.JmsgDB;
import com.bbx.taxi.client.DB.LineDB;
import com.bbx.taxi.client.DB.MyOrder.MyOrderDB;
import com.bbx.taxi.client.DB.MyOrder.MyOrderLocationsDB;
import com.bbx.taxi.client.DB.MyOrder.MyOrderingDB;
import com.bbx.taxi.client.DB.Util.DBcolumns;
//import com.bbx.taxi.client.Fragment.ChangeOrder.ChangeExpressActivity;
import com.bbx.taxi.client.Util.DateFormat;
import com.bbx.taxi.client.Util.FormatUtil;
import com.bbx.taxi.client.Util.Tel;
import com.bbx.taxi.client.Util.ToCity;
import com.bbx.taxi.client.Util.VersionUtils;
import com.bbx.taxi.client.Util.VersionUtils.VersionType;
import com.bbx.taxi.client.widget.MyViewPager;
import com.bbx.taxi.client.widget.Chat.DropdownListView;
import com.bbx.taxi.client.widget.Chat.DropdownListView.OnRefreshListenerHeader;
import com.bbx.taxi.client.widget.Dailog.MessageDialog;
import com.bbx.taxi.client.widget.Dailog.MyAlertDailog;
import com.bbx.taxi.client.widget.Dailog.MyAlertDailog.onClickLeftListener;
import com.bbx.taxi.client.widget.Dailog.MyAlertDailog.onClickRightListener;
import com.bbx.taxi.client.widget.SlidingDrawer.MultiDirectionSlidingDrawer;
import com.bbx.taxi.client.widget.SlidingDrawer.MultiDirectionSlidingDrawer.OnDrawerCloseListener;
import com.bbx.taxi.client.widget.SlidingDrawer.MultiDirectionSlidingDrawer.OnDrawerOpenListener;
import com.bbx.taxi.client.widget.XCArcMenu.XCArcMenuView;
import com.bbx.taxi.client.widget.XCArcMenu.XCArcMenuView.OnMenuItemClickListener;
import com.bbx.taxi.client.widget.XCArcMenu.XCArcMenuView.OnSwitchStateListener;

/**
 * 等待派车跟开始服务界面
 */
public class StartServiceActivity extends BaseMapBBXActivity implements
		OnClickListener, OnRefreshListenerHeader, OnCancelPriceListener,
		OnCancelOrderListener, OnStarListener {
	private final int ONLINE_CHAT = 1000;
	private String MSG_CONTENT = "msg_content";
	private String MSG_USER = "msg_user";
	private int I_ID = 0;// 我的ID
	private int YOU_ID = 1;// 司机的ID
	/** 订单详情的V */
	@InjectView(R.id.viewpager)
	MyViewPager mViewPager;
	@InjectView(R.id.iv_ddxl)
	ImageView iv_ddxl;
	@InjectView(R.id.input_sms)
	EditText input_sms;
	@InjectView(R.id.send_sms)
	TextView send_sms;
	@InjectView(R.id.drawer)
	MultiDirectionSlidingDrawer drawer;
	@InjectView(R.id.handle_text)
	TextView handle_text;
	@InjectView(R.id.btn_change_order)
	Button btn_change_order;// 修改订单
	@InjectView(R.id.btn_order_detail)
	Button btn_order_detail;// 订单详情
	@InjectView(R.id.btn_cancel_order)
	Button btn_cancel_order;// 取消订单
	@InjectView(R.id.open_deawer)
	LinearLayout open_deawer;
	@InjectView(R.id.image_add)
	ImageView image_add;
	@InjectView(R.id.image_face)
	ImageView image_face;
	@InjectView(R.id.layout_top)
	FrameLayout layout_top;
	@InjectView(R.id.layout_startservice)
	RelativeLayout layout_startservice;
	@InjectView(R.id.layout_bottom)
	RelativeLayout layout_bottom;
	@InjectView(R.id.chat_face_container)
	LinearLayout chat_face_container;
	@InjectView(R.id.chat_add_container)
	LinearLayout chat_add_container;
	/** QQ表情ViewPage的点 */
	@InjectView(R.id.dots_face)
	LinearLayout dots_face;
	/** 订单的详情ViewPage的点 */
	@InjectView(R.id.dots_top)
	LinearLayout dots_top;
	@InjectView(R.id.face_viewpager)
	ViewPager face_viewpager;
	@InjectView(R.id.message_chat_listview)
	DropdownListView mListView;
	@InjectView(R.id.bmapView)
	MapView mMapView;
	@InjectView(R.id.include_service_wait)
	RelativeLayout include_service_wait;
	@InjectView(R.id.iv_locate)
	ImageView iv_locate;
	@InjectView(R.id.tv_price)
	TextView tv_price;
	@InjectView(R.id.tv_total_price)
	TextView tv_total_price;
	@InjectView(R.id.tv_estimat_time)
	TextView tv_estimat_time;
	@InjectView(R.id.layout_estimat_time)
	RelativeLayout layout_estimat_time;
	/** 地图的顶部布局 */
	@InjectView(R.id.map_padding)
	RelativeLayout map_padding;
	private BaiduMap mBaiduMap;
	private LayoutInflater inflater;
	/** 客服电话 */
	private ImageButton ib_kftel;
	/** 司机电话 */
	private ImageButton ib_sjtel;
	/** 订单集合 */
	private ArrayList<OfficialOrderList> list_order = new ArrayList<OfficialOrderList>();
	/** 订单消息集合,String订单Id,ArrayList<Map<String, String>>消息集合 */
	private Map<String, ArrayList<Map<String, String>>> map_jsmg = new HashMap<String, ArrayList<Map<String, String>>>();
	/** 订单详情页面集合 */
	private ArrayList<View> list_view = new ArrayList<View>();
	/** 根据订单order_id存储顺序id */
	private Map<String, Integer> map_id = new HashMap<String, Integer>();
	/** 订单详情页面的id */
	private int viewId = 0;
	/** 弧形菜单 */
	private XCArcMenuView mXCArcMenuView;
	/** 弧形菜单，添加订单 */
	private ImageView btn_tjdd;
	/** 弧形菜单父类 */
	private RelativeLayout parent_arcmenu;
	public static List<Expression> expressionList = new ArrayList<Expression>();
	private MyFacePagerAdapter mMyFacePagerAdapter;
	private ArrayList<GridView> grids;
	private int columns = 6, rows = 3, pageExpressionCount = 3 * 6 - 1;
	// --消息列表--//
	private ChatMessageListAdapter chatMessageListAdapter;
	private List<ChatMessage> l_msg = new ArrayList<ChatMessage>();
	private InitTask mInitTask;
	private int type_activity;
	private MyOrderingDB db_myordering;// 我的进行中的订单数据库
	private MyOrderDB db_myorder;// 我的进行中的订单数据库
	private MyOrderLocationsDB db_locations;// 我的订单的Locations数据库
	private JmsgDB db_jmsg;
	private Intent mIntent;
	/** 司机位置 */
	private LatLng siLatLng;
	private Handler mHandler = new Handler() {
		public void handleMessage(android.os.Message msg) {
			switch (msg.what) {
			case 0:
				try {
					if (mBaiduMap != null)
						mBaiduMap.setMyLocationEnabled((Boolean) msg.obj);
				} catch (Exception e) {
				}

				break;
			default:
				break;
			}
		};
	};
	private MyPosition_Run position_run;
	MyAlertDailog dialog;
	// 初始化全局 bitmap 信息，不用时及时 recycle
	BitmapDescriptor bdA = BitmapDescriptorFactory
			.fromResource(R.drawable.icon_addcar);
	BitmapDescriptor bd_start = BitmapDescriptorFactory
			.fromResource(R.drawable.icon_map_add);
	BitmapDescriptor bd_end = BitmapDescriptorFactory
			.fromResource(R.drawable.icon_map_end);
	/** 司机覆盖物 */
	private Marker mMarkerA;
	/** 起始点覆盖物 */
	private Marker mMarker_start;
	/** 终点覆盖物 */
	private Marker mMarker_end;
	/** 等待派车的父布局 */
	private RelativeLayout layout_wait;
	/** 服务站的父布局 */
	private LinearLayout layout_service;
	/** 是否启动打开服务中的等待界面 */
	private boolean isOpenServiceWait = true;
	public List<String> sn_position_list = new ArrayList<String>();
	private LineDB db_line;// 线路数据库
	/** 判断是否可点击 */
	public boolean isClick = true;
	/** 地图尺寸级别,单位以KM计算 */
	public double[] Map_Level = new double[] { 2000, 2000, 2000, 2000, 1000,
			500, 200, 100, 50, 25, 20, 10, 5, 2, 1, 0.5, 0.2, 0.1, 0.05, 0.02,
			0.01 };
	public InfoWindow mInfoWindow;
	public InfoWindow mInfoWindow_price;
	private Resources res;
	int down_y = 0;
	/** 估计时间20分钟 */
	private int estimat_time = 30;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
		setContentView(R.layout.startservice);
		super.onCreate(savedInstanceState);
	}

	String extra_order_id;

	@Override
	protected void initView() {
		super.initView();
		layout_startservice.setVisibility(View.GONE);
		layout_top.setVisibility(View.GONE);
		res = getResources();
		mBaiduMap = mMapView.getMap();
		iv_locate.setOnClickListener(this);
		dialog = new MyAlertDailog(this);
		position_run = new MyPosition_Run();
		db_myordering = new MyOrderingDB(this);
		db_myorder = new MyOrderDB(this);
		db_jmsg = new JmsgDB(this);
		db_locations = new MyOrderLocationsDB(this);
		mIntent = getIntent();
		type_activity = mIntent.getExtras().getInt(OrderMsg.extra_type);
		// initArcMenu();
		initDrawer();
		initChat();
		if (loaddialog != null && !loaddialog.isShowing()) {
			loaddialog.show();
		}
		mInitTask = new InitTask();
		mInitTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);

	}

	public class InitTask extends AsyncTask<Object, Object, Object> {
		protected Void doInBackground(Object... params) {
			switch (type_activity) {
			case 0:// 主界面跳转过来的
				list_order.clear();
				list_order.addAll(db_myordering.onReadDB_ing(context,
						MyOrderActivity.num_ing, true));
				break;
			case 1:// 列表跳转过来的
				list_order.clear();
				list_order.addAll(db_myordering.onReadDB_ing(context,
						MyOrderActivity.num_ing, true));
				extra_order_id = mIntent.getExtras().getString(
						OrderMsg.extra_order_id);
				break;
			}

			return null;
		}

		protected void onPostExecute(Object result) {
			// 根据订单Id存储顺序id
			for (int i = 0; i < list_order.size(); i++) {
				map_id.put(list_order.get(i).getOrder_id(), i);
			}
			if (extra_order_id != null) {
				try {
					viewId = map_id.get(extra_order_id);
				} catch (Exception e) {
					MyOrderTask.getInstance(context, MyOrderActivity.num_ing,
							Value.TYPE_ING, Value.OWNALL,
							MyOrderTask.TYPE_REFRESH).setOnOrderFinishListener(
							StartServiceActivity.this);
					return;
				}

			}
			initPage();
			onShowTitleStatus();
			initMap();
			if (loaddialog != null) {
				loaddialog.dismiss();
			}
			super.onPostExecute(result);
		}
	};

	/**
	 * 初始化订单详情的ViewPage
	 */
	protected void initPage() {
		layout_top.setVisibility(View.VISIBLE);
		layout_startservice.setVisibility(View.VISIBLE);
		new Handler().postDelayed(new Runnable() {

			@Override
			public void run() {
				int height = layout_top.getMeasuredHeight();
				map_padding.setPadding(0, height, 0, 0);
			}
		}, 200);
		LayoutInflater mInflater = getLayoutInflater();// 获取mInflater，用于加载布局
		list_view.clear();
		map_jsmg.clear();
		// 初始化多个订单的布局状态，这里先默认为等待派车，实际要根据接口返回来的值，来显示布局样式
		for (int i = 0; i < list_order.size(); i++) {
			View v = mInflater.inflate(R.layout.item_vp_order_detail, null);// 加载布局
			list_view.add(v);
			// 监听客服电话跟司机电话
			((ImageButton) v.findViewById(R.id.ib_sjtel))
					.setOnClickListener(this);
			ImageButton ib_kftel = ((ImageButton) v.findViewById(R.id.ib_kftel));
			ib_kftel.setVisibility(View.VISIBLE);
			ib_kftel.setOnClickListener(this);
			onSetContent(i, v);
			// 不存在该Id不添加消息，怕刷新的时候又调用了initPage，导致消息重复添加

			if (!map_jsmg.containsKey(list_order.get(i).getOrder_id())) {
				ArrayList<Map<String, String>> al_jsmg = new ArrayList<Map<String, String>>();
				al_jsmg = onRead_jsmg(list_order.get(i).getOrder_id());
				map_jsmg.put(list_order.get(i).getOrder_id(), al_jsmg);
			}
		}
		mViewPager.setAdapter(new MyPagerAdapter(list_view));// 绑定数据
		mViewPager.setCurrentItem(viewId);// 设置默认子试图
		isCurrentService(viewId);
		mViewPager.setOnPageChangeListener(new OnPageChangeListener() {

			@Override
			public void onPageScrolled(int arg0, float arg1, int arg2) {
				// TODO Auto-generated method stub

			}

			@Override
			public void onPageScrollStateChanged(int position) {

			}

			@Override
			public void onPageSelected(int position) {
				for (int i = 0; i < dots_top.getChildCount(); i++) {
					dots_top.getChildAt(i).setSelected(false);
				}
				dots_top.getChildAt(position).setSelected(true);
				viewId = position;
				isCurrentService(viewId);
				onShowTitleStatus();

			}
		});
		int chat_dot_margin_lr = (int) getResources().getDimension(
				R.dimen.chat_dot_margin_lr);
		int chat_dot_wh_big = (int) getResources().getDimension(
				R.dimen.chat_dot_wh_big);
		dots_top.removeAllViews();
		for (int i = 0; i < list_view.size(); i++) {
			android.widget.LinearLayout.LayoutParams lp = new android.widget.LinearLayout.LayoutParams(
					chat_dot_wh_big, chat_dot_wh_big);
			lp.leftMargin = chat_dot_margin_lr;
			lp.rightMargin = chat_dot_margin_lr;
			dots_top.addView(dotsItem(i), lp);
		}
		dots_top.getChildAt(viewId).setSelected(true);
		closeDetail();
	}

	/**
	 * 弧形菜单的初始化
	 */
	private void initArcMenu() {
		// 弧形菜单
		mXCArcMenuView = (XCArcMenuView) findViewById(R.id.include_arcmenu)
				.findViewById(R.id.arcmenu);
		btn_tjdd = (ImageView) findViewById(R.id.include_arcmenu).findViewById(
				R.id.btn_tjdd);
		parent_arcmenu = (RelativeLayout) findViewById(R.id.include_arcmenu);
		mXCArcMenuView
				.setOnMenuItemClickListener(new OnMenuItemClickListener() {
					@Override
					public void onClick(View view, int pos) {
						closeArcMenu();
						String tag = (String) view.getTag();
						Toast.makeText(StartServiceActivity.this, tag,
								Toast.LENGTH_SHORT).show();
						int viewpageId = Value.ORDER_TYPE_PC;
						if (tag.equals("小件快递")) {
							viewpageId = Value.VIEWID_KJ;
						} else if (tag.equals("拼车出行")) {
							viewpageId = Value.VIEWID_PC;
						} else if (tag.equals("包车出行")) {
							viewpageId = Value.VIEWID_BC;
						}
						MainAttribute main = MainAttribute.getInstance();
						main.onRestoreAttribute();
						mApplication.onStartLocation();
						Intent intent = new Intent();
						intent.setClass(StartServiceActivity.this,
								MainActivity.class);
						intent.putExtra(MainMsg.extra_viewpageId, viewpageId);
						intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // 注意本行的FLAG设置
						startActivity(intent);
					}
				});
		mXCArcMenuView.setOnSwitchStateListener(new OnSwitchStateListener() {
			@Override
			public void onSwitchState(boolean state) {
				if (state) {
					showArcMenu();
				} else {
					closeArcMenu();
				}

			}
		});
	}

	/**
	 * 抽屉初始化
	 */
	private void initDrawer() {
		open_deawer.setOnClickListener(this);
		drawer.setOnClickListener(this);
		drawer.setOnDrawerCloseListener(new OnDrawerCloseListener() {

			@Override
			public void onDrawerClosed() {
				// 点这里，更多订单操作。
				handle_text.setText(R.string.drawer_open);
				open_deawer.setVisibility(View.VISIBLE);
				drawer.setVisibility(View.GONE);
				mViewPager.setNoScroll(false);
				isOpenServiceWait = true;
			}
		});
		drawer.setOnDrawerOpenListener(new OnDrawerOpenListener() {

			@Override
			public void onDrawerOpened() {
				// 收起对话，查看地图。
				handle_text.setText(R.string.drawer_close);
				mViewPager.setNoScroll(true);
				isOpenServiceWait = false;
			}
		});
	}

	/**
	 * 聊天界面列表初始化
	 */
	private void initChat() {
		send_sms.setOnClickListener(this);
		image_add.setOnClickListener(this);
		image_face.setOnClickListener(this);
		btn_change_order.setOnClickListener(this);
		btn_order_detail.setOnClickListener(this);
		btn_cancel_order.setOnClickListener(this);
		mListView.setOnRefreshListenerHead(this);
		chatMessageListAdapter = new ChatMessageListAdapter(l_msg, this);
		mListView.setAdapter(chatMessageListAdapter);
		mListView.setOnTouchListener(new OnTouchListener() {
			@Override
			public boolean onTouch(View arg0, MotionEvent arg1) {
				// if (arg1.getAction() == MotionEvent.ACTION_DOWN) {
				// if (chat_face_container.getVisibility() == View.VISIBLE) {
				// chat_face_container.setVisibility(View.GONE);
				// }
				// if (chat_add_container.getVisibility() == View.VISIBLE) {
				// chat_add_container.setVisibility(View.GONE);
				// }
				// hideSoftInputView();
				// }
				return false;
			}
		});
	}

	/**
	 * 地图初始化
	 */
	private void initMap() {
		mMapView.showZoomControls(false);
		mMapView.showScaleControl(true);
		Message msg = new Message();
		msg.what = 0;
		int status = Integer.parseInt(list_order.get(viewId).getOrder_status());
		if (status == Value.ORDER_STATUS_ONCAR
				|| status == Value.ORDER_STATUS_APPOINT) {
			msg.obj = (Boolean) false;
			mHandler.sendMessageDelayed(msg, 100);
		}

	}

	@Override
	protected void initData() {
		db_line = new LineDB(context);
	}

	@Override
	protected void desotryItems() {
		// TODO Auto-generated method stub

	}

	/**
	 * 订单详情切换和表情页切换时，底部小圆点
	 * 
	 * @param position
	 * @return
	 */
	private ImageView dotsItem(int position) {
		View layout = inflater.inflate(R.layout.dot_image, null);
		ImageView iv = (ImageView) layout.findViewById(R.id.face_dot);
		iv.setId(position);
		return iv;
	}

	@Override
	public void onClick(View v) {
		if (!isClick)
			return;
		switch (v.getId()) {
		case R.id.iv_left:
			finish();
			break;
		case R.id.tv_right:// 取消订单
			// Offciail_CancelPriceBuild mOffciail_CancelPriceBuild = new
			// Offciail_CancelPriceBuild(this);
			// mOffciail_CancelPriceBuild.order_id=list_order.get(viewId).getOrder_id();
			// MyCancelPriceTask.getInstance(context,
			// mOffciail_CancelPriceBuild).setOnCancelPriceListener(this);
			onCancel();

			break;
		case R.id.send_sms:// 发送消息
			// sendMsgText(input_sms.getText().toString(), I_ID,
			// DateFormat.getCurrentTime());
			// onSaveSendMsg(input_sms.getText().toString(), I_ID,
			// DateFormat.getCurrentTime());
			// input_sms.postDelayed(new Runnable() {
			//
			// @Override
			// public void run() {
			// sendMsgText("对不起", YOU_ID, DateFormat.getCurrentTime());
			// onSaveSendMsg("对不起", YOU_ID, DateFormat.getCurrentTime());
			// }
			// }, 1000);
			break;
		case R.id.image_add:// +
			hideSoftInputView();// 隐藏软键盘
			if (chat_face_container.getVisibility() == View.VISIBLE) {
				chat_face_container.setVisibility(View.GONE);
			}
			if (chat_add_container.getVisibility() == View.GONE) {
				chat_add_container.setVisibility(View.VISIBLE);
			} else {
				chat_add_container.setVisibility(View.GONE);
			}
			break;
		case R.id.image_face:// 表情
			hideSoftInputView();// 隐藏软键盘
			if (chat_add_container.getVisibility() == View.VISIBLE) {
				chat_add_container.setVisibility(View.GONE);
			}
			if (chat_face_container.getVisibility() == View.GONE) {
				chat_face_container.setVisibility(View.VISIBLE);
			} else {
				chat_face_container.setVisibility(View.GONE);
			}
			break;
		case R.id.btn_change_order:// 修改订单
			// hideSoftInputView();// 隐藏软键盘
			// if (chat_face_container.getVisibility() == View.VISIBLE) {
			// chat_face_container.setVisibility(View.GONE);
			// }
			// if (chat_add_container.getVisibility() == View.GONE) {
			// chat_add_container.setVisibility(View.VISIBLE);
			// } else {
			// chat_add_container.setVisibility(View.GONE);
			// }
			Intent intent = null;
			if (Integer.parseInt(list_order.get(viewId).getOrder_type()) == Value.ORDER_TYPE_KJ) {
				// intent = new Intent(this, ChangeExpressActivity.class);
			} else {
				intent = new Intent(this, ChangeOrderActivity.class);
				intent.putExtra(OrderMsg.change_order_type,
						list_order.get(viewId).getOrder_type());
			}
			intent.putExtra(OrderMsg.change_old_order_id, list_order
					.get(viewId).getOrder_id());
			ChangeAttribute change = ChangeAttribute.getInstance();
			change.setAttribute(list_order.get(viewId));
			startActivityForResult(intent, requestCode);
			break;
		case R.id.btn_order_detail:// 订单详情
			sendMsgText(getString(R.string.order_detail), I_ID,
					DateFormat.getCurrentTime());
			onSaveSendMsg(getString(R.string.order_detail), I_ID,
					DateFormat.getCurrentTime());
			input_sms.postDelayed(new Runnable() {

				@Override
				public void run() {
					String number_string = "";
					String round_trip = null;
					String name = null;
					String name2 = null;
					String start_name_s = "";
					String end_name_s = "";
					String message = null;
					boolean Is_mutiple_oncar = false;// 是否多地点上下车
					switch (Integer.parseInt(list_order.get(viewId)
							.getOrder_type())) {
					case Value.ORDER_TYPE_KJ:
						name = "  "
								+ ((list_order.get(viewId).getOrderDetail()
										.getStart().getName().equals("")) ? "本人"
										: list_order.get(viewId)
												.getOrderDetail().getStart()
												.getName());
						name2 = "  "
								+ (list_order.get(viewId).getOrderDetail()
										.getEnd().getName()
										+ "  "
										+ FormatUtil
												.onFormatTelephone(list_order
														.get(viewId)
														.getOrderDetail()
														.getEnd().getPhone()) + "\n");
						start_name_s = "寄件信息：";
						end_name_s = "收件信息：";
						String volume = "";
						String weight = "";
						// try {
						// switch (Integer.parseInt(list_order.get(viewId)
						// .getOrderDetail().getVolume())) {
						// case Value.KJ_VOLUME_S:
						// volume = getString(R.string.goods_small);
						// break;
						// case Value.KJ_VOLUME_M:
						// volume = getString(R.string.goods_middle);
						// break;
						// case Value.KJ_VOLUME_B:
						// volume = getString(R.string.goods_big);
						// break;
						// }
						// } catch (Exception e) {
						// 转换失败，则直接显示
						// volume = list_order.get(viewId).getOrderDetail()
						// .getVolume();
						// }

						// try {
						// if (Integer.parseInt(list_order.get(viewId)
						// .getOrderDetail().getWeight()) ==
						// Value.KJ_WEIGHT_0_5) {
						// weight = getString(R.string.kg_0_5);
						// } else if (Integer.parseInt(list_order.get(viewId)
						// .getOrderDetail().getWeight()) ==
						// Value.KJ_WEIGHT_6_10) {
						// weight = getString(R.string.kg_6_10);
						// } else if (Integer.parseInt(list_order.get(viewId)
						// .getOrderDetail().getWeight()) ==
						// Value.KJ_WEIGHT_11_15) {
						// weight = getString(R.string.kg_11_15);
						// }
						// } catch (Exception e) {
						// // 转换失败，则直接显示
						// weight = list_order.get(viewId).getOrderDetail()
						// .getWeight();
						// }

						// number_string = "货品详情：" + weight + ";" + volume +
						// ";";
						message = "备注：" + list_order.get(viewId).getMessage();
						break;
					case Value.ORDER_TYPE_PC:
						name = "\n乘车人："
								+ ((list_order.get(viewId).getOrderDetail()
										.getStart().getName().equals("")) ? "本人"
										: list_order.get(viewId)
												.getOrderDetail().getStart()
												.getName());
						;
						start_name_s = "出发地点：";
						end_name_s = "目的地：";
						// number_string = "\n人数："
						// + list_order.get(viewId).getOrderDetail()
						// .getCount() + "人";
						message = "\n备注：" + list_order.get(viewId).getMessage();
						break;
					case Value.ORDER_TYPE_BC:
						name = "\n乘车人："
								+ ((list_order.get(viewId).getOrderDetail()
										.getStart().getName().equals("")) ? "本人"
										: list_order.get(viewId)
												.getOrderDetail().getStart()
												.getName());
						;
						start_name_s = "出发地点：";
						end_name_s = "目的地：";
						// Is_mutiple_oncar =
						// list_order.get(viewId).getOrderDetail().getIs_mutiple_oncar()==1?true:false;
						// number_string = "\n包车数量："
						// + list_order.get(viewId).getOrderDetail()
						// .getCount() + "辆";
						message = "\n备注：" + list_order.get(viewId).getMessage();
						break;
					case Value.ORDER_TYPE_SN:
						name = "\n乘车人："
								+ ((list_order.get(viewId).getOrderDetail()
										.getStart().getName().equals("")) ? "本人"
										: list_order.get(viewId)
												.getOrderDetail().getStart()
												.getName());
						;
						start_name_s = "出发地点：";
						end_name_s = "目的地：";
						break;
					case Value.ORDER_TYPE_GW:
						round_trip = "\n出行方式：";
						name = "\n乘车人："
								+ ((list_order.get(viewId).getOrderDetail()
										.getStart().getName().equals("")) ? "本人"
										: list_order.get(viewId)
												.getOrderDetail().getStart()
												.getName());
						;
						start_name_s = "出发地点：";
						end_name_s = "目的地：";
						round_trip += (list_order.get(viewId).getRound_trip()
								.equals(Value.ROUND_TRIP) ? "往返" : "单程");
						break;
					}
					String xinxi = "出行时间："
							+ list_order.get(viewId).getAppoint_time()
							+ "\n"
							+ start_name_s
							+ list_order.get(viewId).getOrderDetail()
									.getStart().getAddress()
							+ ((name2 != null) ? name
									+ "  "
									+ FormatUtil.onFormatTelephone(list_order
											.get(viewId).getOrderDetail()
											.getStart().getPhone()) + "\n"
									: "\n")
							+ end_name_s
							+ list_order.get(viewId).getOrderDetail().getEnd()
									.getAddress()
							+ ((name2 == null) ? name
									+ "  "
									+ FormatUtil.onFormatTelephone(list_order
											.get(viewId).getOrderDetail()
											.getStart().getPhone()) + "" : "")
							+ (name2 != null ? name2 : "") + number_string
							+ ((message != null) ? message : "")
							+ (Is_mutiple_oncar ? "\n需要多地点上下车" : "")
							+ ((round_trip != null) ? round_trip : "");
					sendMsgText(xinxi, YOU_ID, DateFormat.getCurrentTime());
					onSaveSendMsg(xinxi, YOU_ID, DateFormat.getCurrentTime());
				}
			}, 1000);
			break;
		case R.id.btn_cancel_order:
			ToastUtil.showToast(context, R.string.order_cancel);
			// hideSoftInputView();// 隐藏软键盘
			// if (chat_face_container.getVisibility() == View.VISIBLE) {
			// chat_face_container.setVisibility(View.GONE);
			// }
			// if (chat_add_container.getVisibility() == View.GONE) {
			// chat_add_container.setVisibility(View.VISIBLE);
			// } else {
			// chat_add_container.setVisibility(View.GONE);
			// }
			startActivityForResult(
					new Intent(this, CancelOrderActivity.class).putExtra(
							OrderMsg.cancel_order_id, list_order.get(viewId)
									.getOrder_id()), requestCode);
			break;
		case R.id.open_deawer:// 打开抽屉
			open_deawer.setVisibility(View.GONE);
			drawer.setVisibility(View.VISIBLE);
			drawer.animateOpen();
			break;
		// 拨打司机电话
		case R.id.ib_sjtel:
			// 根据viewId判断司机的电话经行拨打
			ToastUtil.showToast(context, R.string.tel_si);
			// 用intent启动拨打电话
			startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse("tel:"
					+ list_order.get(viewId).getDriver_phone())));
			break;
		// 拨打客服电话
		case R.id.ib_kftel:
			Tel.onTel(context, Value.TEL_KF);
			break;
		case R.id.iv_locate:
			setCenterPoint(mApplication.latitude, mApplication.longitude, 13);
			break;

		default:
			super.onClick(v);
			break;
		}
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		if (null == mMyFacePagerAdapter) {
			initExpression();
			List<List<Expression>> lists = initGridViewData();// 填充GridView数据
			grids = new ArrayList<GridView>();
			int gv_padding_lr = (int) getResources().getDimension(
					R.dimen.chat_gv_padding_lr);
			int gv_padding_bt = (int) getResources().getDimension(
					R.dimen.chat_gv_padding_bt);
			int gv_spacing = (int) getResources().getDimension(
					R.dimen.chat_gv_spacing);
			int chat_dot_margin_lr = (int) getResources().getDimension(
					R.dimen.chat_dot_margin_lr);
			int chat_dot_wh = (int) getResources().getDimension(
					R.dimen.chat_dot_wh);
			for (int i = 0; i < lists.size(); i++) {
				List<Expression> l = lists.get(i);
				if (null != l) {
					// --生成当前GridView--//
					final GridView gv = new GridView(this);
					gv.setLayoutParams(new LayoutParams(
							LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
					gv.setNumColumns(columns);
					gv.setGravity(Gravity.CENTER);
					gv.setPadding(gv_padding_lr, gv_padding_bt, gv_padding_lr,
							0);
					gv.setHorizontalSpacing(gv_spacing);
					gv.setVerticalSpacing(gv_spacing);
					ExpressionImageAdapter expressionImageAdapter = new ExpressionImageAdapter(
							this, l);
					gv.setAdapter(expressionImageAdapter);
					// --点击列表事件处理--//
					gv.setOnItemClickListener(new OnItemClickListener() {
						/*
						 * (non-Javadoc)
						 * 
						 * @see android.widget.AdapterView.OnItemClickListener#
						 * onItemClick(android.widget.AdapterView,
						 * android.view.View, int, long)
						 */
						@Override
						public void onItemClick(AdapterView<?> arg0, View arg1,
								int arg2, long arg3) {
							Expression e = (Expression) gv
									.getItemAtPosition(arg2);
							LogUtils.v("_____________", "点击表情_" + e.code);
							int index = input_sms.getSelectionStart();
							Editable edit = input_sms.getEditableText();// 获取EditText的文字
							String content_all = edit.toString();
							String content_forward = content_all.substring(0,
									index);
							LogUtils.v("_____________", "content_all = "
									+ content_all + "|content_forward = "
									+ content_forward + "|");
							String reg = "\\[#[1-9][0-9]?\\]";
							if (e.getDrableId() < 0) {// 点击删除按钮
								if (index > 0) {
									boolean delExpression = false;
									Pattern p = Pattern.compile(reg);
									Matcher matcher = p
											.matcher(content_forward);
									// 因为这里表情代码最长为5，所以这里减5
									boolean found = false;
									if (content_forward.length() >= 4) {// 如果光标前字符少于4个，说明不可能为表情
										if (content_forward.length() == 4) {
											found = matcher
													.find(content_forward
															.length() - 4);
										} else {
											found = matcher
													.find(content_forward
															.length() - 5);
										}
										if (found) {
											String flag = matcher.group();
											if (content_forward.substring(
													content_forward.length()
															- flag.length(),
													content_forward.length())
													.equals(flag)) {
												delExpression = true;
												edit.delete(
														index - flag.length(),
														index);
											}
										}
									}
									if (!delExpression) {
										edit.delete(index - 1, index);
									}
								}
							} else {
								ImageSpan imageSpan = new ImageSpan(
										BitmapFactory.decodeResource(
												getResources(), e.drableId));
								SpannableString spannableString = new SpannableString(
										e.code);
								spannableString.setSpan(imageSpan, 0,
										e.code.length(),
										Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

								LogUtils.v("_____________", "spannableString="
										+ spannableString.toString()
										+ "__index=" + index);

								if (index < 0 || index >= edit.length()) {
									edit.append(spannableString);
								} else {
									edit.insert(index, spannableString);
								}
							}
						}
					});
					grids.add(gv);
					// --生成索引图--//
					android.widget.LinearLayout.LayoutParams lp = new android.widget.LinearLayout.LayoutParams(
							chat_dot_wh, chat_dot_wh);
					lp.leftMargin = chat_dot_margin_lr;
					lp.rightMargin = chat_dot_margin_lr;
					dots_face.addView(dotsItem(i), lp);
					dots_face.getChildAt(0).setSelected(true);
				}
			}
			mMyFacePagerAdapter = new MyFacePagerAdapter(grids);
			face_viewpager.setAdapter(mMyFacePagerAdapter);
			face_viewpager.setOnPageChangeListener(new OnPageChangeListener() {

				@Override
				public void onPageScrolled(int arg0, float arg1, int arg2) {
					// TODO Auto-generated method stub

				}

				@Override
				public void onPageScrollStateChanged(int arg0) {
					// TODO Auto-generated method stub

				}

				@Override
				public void onPageSelected(int position) {
					for (int i = 0; i < dots_face.getChildCount(); i++) {
						dots_face.getChildAt(i).setSelected(false);
					}
					dots_face.getChildAt(position).setSelected(true);

				}
			});
			dots_face.getChildAt(0).setSelected(true);
		}

		// tv_chat_title.setText(Html.fromHtml("<img src=\""+2130837523+"\" />",
		// imageGetter_resource, null));
	}

	/**
	 * 填充GridView所需要的数据
	 */
	private List<List<Expression>> initGridViewData() {
		List<List<Expression>> lists = new ArrayList<List<Expression>>();
		List<Expression> list = null;
		for (int i = 0; i < expressionList.size(); i++) {
			if (i % pageExpressionCount == 0) {// 一页数据已填充完成
				if (null != list) {
					list.add(new Expression(-1, "backSpace"));// 添加删除键
					lists.add(list);
				}
				list = new ArrayList<Expression>();
			}
			list.add(expressionList.get(i));
			// 最后一个表情，并且不是当前页最后一个表情时，后面添加删除键
			if (i >= expressionList.size() - 1) {
				list.add(new Expression(-1, "backSpace"));// 添加删除键
				lists.add(list);
			}
		}
		return lists;
	}

	/**
	 * 初始化表情信息
	 */
	public static void initExpression() {
		Expression exp1 = new Expression(R.drawable.e_1, "[#1]");
		Expression exp2 = new Expression(R.drawable.e_2, "[#2]");
		Expression exp3 = new Expression(R.drawable.e_3, "[#3]");
		Expression exp4 = new Expression(R.drawable.e_4, "[#4]");
		Expression exp5 = new Expression(R.drawable.e_5, "[#5]");
		Expression exp6 = new Expression(R.drawable.e_6, "[#6]");
		Expression exp7 = new Expression(R.drawable.e_7, "[#7]");
		Expression exp8 = new Expression(R.drawable.e_8, "[#8]");
		Expression exp9 = new Expression(R.drawable.e_9, "[#9]");
		Expression exp10 = new Expression(R.drawable.e_10, "[#10]");

		Expression exp11 = new Expression(R.drawable.e_11, "[#11]");
		Expression exp12 = new Expression(R.drawable.e_12, "[#12]");
		Expression exp13 = new Expression(R.drawable.e_13, "[#13]");
		Expression exp14 = new Expression(R.drawable.e_14, "[#14]");
		Expression exp15 = new Expression(R.drawable.e_15, "[#15]");
		Expression exp16 = new Expression(R.drawable.e_16, "[#16]");
		Expression exp17 = new Expression(R.drawable.e_17, "[#17]");
		Expression exp18 = new Expression(R.drawable.e_18, "[#18]");
		Expression exp19 = new Expression(R.drawable.e_19, "[#19]");
		Expression exp20 = new Expression(R.drawable.e_20, "[#20]");

		Expression exp21 = new Expression(R.drawable.e_21, "[#21]");
		Expression exp22 = new Expression(R.drawable.e_22, "[#22]");
		Expression exp23 = new Expression(R.drawable.e_23, "[#23]");
		Expression exp24 = new Expression(R.drawable.e_24, "[#24]");
		Expression exp25 = new Expression(R.drawable.e_25, "[#25]");
		Expression exp26 = new Expression(R.drawable.e_26, "[#26]");
		Expression exp27 = new Expression(R.drawable.e_27, "[#27]");
		Expression exp28 = new Expression(R.drawable.e_28, "[#28]");
		Expression exp29 = new Expression(R.drawable.e_29, "[#29]");
		Expression exp30 = new Expression(R.drawable.e_30, "[#30]");

		Expression exp31 = new Expression(R.drawable.e_31, "[#31]");
		Expression exp32 = new Expression(R.drawable.e_32, "[#32]");
		Expression exp33 = new Expression(R.drawable.e_33, "[#33]");
		Expression exp34 = new Expression(R.drawable.e_34, "[#34]");
		Expression exp35 = new Expression(R.drawable.e_35, "[#35]");
		Expression exp36 = new Expression(R.drawable.e_36, "[#36]");
		Expression exp37 = new Expression(R.drawable.e_37, "[#37]");
		Expression exp38 = new Expression(R.drawable.e_38, "[#38]");
		Expression exp39 = new Expression(R.drawable.e_39, "[#39]");
		Expression exp40 = new Expression(R.drawable.e_40, "[#40]");

		Expression exp41 = new Expression(R.drawable.e_41, "[#41]");
		Expression exp42 = new Expression(R.drawable.e_42, "[#42]");
		Expression exp43 = new Expression(R.drawable.e_43, "[#43]");
		Expression exp44 = new Expression(R.drawable.e_44, "[#44]");
		Expression exp45 = new Expression(R.drawable.e_45, "[#45]");
		Expression exp46 = new Expression(R.drawable.e_46, "[#46]");
		Expression exp47 = new Expression(R.drawable.e_47, "[#47]");
		Expression exp48 = new Expression(R.drawable.e_48, "[#48]");
		Expression exp49 = new Expression(R.drawable.e_49, "[#49]");
		Expression exp50 = new Expression(R.drawable.e_50, "[#50]");

		Expression exp51 = new Expression(R.drawable.e_51, "[#51]");
		Expression exp52 = new Expression(R.drawable.e_52, "[#52]");
		Expression exp53 = new Expression(R.drawable.e_53, "[#53]");
		Expression exp54 = new Expression(R.drawable.e_54, "[#54]");
		Expression exp55 = new Expression(R.drawable.e_55, "[#55]");
		Expression exp56 = new Expression(R.drawable.e_56, "[#56]");
		Expression exp57 = new Expression(R.drawable.e_57, "[#57]");
		Expression exp58 = new Expression(R.drawable.e_58, "[#58]");
		Expression exp59 = new Expression(R.drawable.e_59, "[#59]");
		Expression exp60 = new Expression(R.drawable.e_60, "[#60]");

		Expression exp61 = new Expression(R.drawable.e_61, "[#61]");
		Expression exp62 = new Expression(R.drawable.e_62, "[#62]");
		Expression exp63 = new Expression(R.drawable.e_63, "[#63]");
		Expression exp64 = new Expression(R.drawable.e_64, "[#64]");

		expressionList.add(exp1);
		expressionList.add(exp2);
		expressionList.add(exp3);
		expressionList.add(exp4);
		expressionList.add(exp5);
		expressionList.add(exp6);
		expressionList.add(exp7);
		expressionList.add(exp8);
		expressionList.add(exp9);
		expressionList.add(exp10);

		expressionList.add(exp11);
		expressionList.add(exp12);
		expressionList.add(exp13);
		expressionList.add(exp14);
		expressionList.add(exp15);
		expressionList.add(exp16);
		expressionList.add(exp17);
		expressionList.add(exp18);
		expressionList.add(exp19);
		expressionList.add(exp20);

		expressionList.add(exp21);
		expressionList.add(exp22);
		expressionList.add(exp23);
		expressionList.add(exp24);
		expressionList.add(exp25);
		expressionList.add(exp26);
		expressionList.add(exp27);
		expressionList.add(exp28);
		expressionList.add(exp29);
		expressionList.add(exp30);

		expressionList.add(exp31);
		expressionList.add(exp32);
		expressionList.add(exp33);
		expressionList.add(exp34);
		expressionList.add(exp35);
		expressionList.add(exp36);
		expressionList.add(exp37);
		expressionList.add(exp38);
		expressionList.add(exp39);
		expressionList.add(exp40);

		expressionList.add(exp41);
		expressionList.add(exp42);
		expressionList.add(exp43);
		expressionList.add(exp44);
		expressionList.add(exp45);
		expressionList.add(exp46);
		expressionList.add(exp47);
		expressionList.add(exp48);
		expressionList.add(exp49);
		expressionList.add(exp50);

		expressionList.add(exp51);
		expressionList.add(exp52);
		expressionList.add(exp53);
		expressionList.add(exp54);
		expressionList.add(exp55);
		expressionList.add(exp56);
		expressionList.add(exp57);
		expressionList.add(exp58);
		expressionList.add(exp59);
		expressionList.add(exp60);

		expressionList.add(exp61);
		expressionList.add(exp62);
		expressionList.add(exp63);
		expressionList.add(exp64);
	}
	
	/**
	 * 执行发送消息 文本类型
	 * 
	 * @param content
	 */
	public void sendMsgText(String content, int userID, String time) {
		ChatMessage cm = new ChatMessage();
		cm.chatMsg = content;
		cm.nickName = "nickName_I";
		cm.userID = userID;
		cm.time = time;
		LogUtils.v("_____________", "msg=" + cm.chatMsg + "|nickName="
				+ cm.nickName + "|userID=" + cm.userID);
		this.l_msg.add(cm);
		if (null!= chatMessageListAdapter) {
			chatMessageListAdapter.setL(l_msg);
			chatMessageListAdapter.notifyDataSetChanged();
		}
		input_sms.setText("");
	}

	public void onSaveSendMsg(String content, int userID, String time) {
		// 存在这个Id
		if (map_jsmg.containsKey(list_order.get(viewId).getOrder_id())) {
			ArrayList<Map<String, String>> list_jsmg = map_jsmg.get(list_order
					.get(viewId).getOrder_id());
			Map<String, String> map = new HashMap<String, String>();
			map.put(MSG_CONTENT, content);
			map.put(MSG_USER, userID + "");
			map.put(DBcolumns.MESSAGE_TIME, time);
			map.put(DBcolumns.MESSAGE_TYPE, ONLINE_CHAT + "");
			map.put(DBcolumns.MESSAGE_TIME, DateFormat.getCurrentTime());
			list_jsmg.add(map);
			map_jsmg.put(list_order.get(viewId).getOrder_id(), list_jsmg);
		}
	}

	/**
	 * 隐藏软键盘
	 */
	public void hideSoftInputView() {
		InputMethodManager manager = ((InputMethodManager) this
				.getSystemService(Activity.INPUT_METHOD_SERVICE));
		if (getWindow().getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) {
			if (getCurrentFocus() != null)
				manager.hideSoftInputFromWindow(getCurrentFocus()
						.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
		}
	}

	/**
	 * 展开弧形菜单
	 */
	public void showArcMenu() {
		isClick = false;
		parent_arcmenu.setBackgroundColor(getResources().getColor(
				R.color.transparent_80));
		layout_top.setForeground(getResources().getDrawable(
				R.color.transparent_80));
		btn_tjdd.setImageDrawable(getResources().getDrawable(
				R.drawable.btn_tjdd_cl));
		layout_top.setClickable(true);
		parent_arcmenu.setClickable(true);
	}

	/**
	 * 关闭弧形菜单
	 */
	public void closeArcMenu() {
		isClick = true;
		parent_arcmenu.setBackgroundColor(getResources().getColor(
				R.color.transparent));
		layout_top.setForeground(getResources()
				.getDrawable(R.color.transparent));
		btn_tjdd.setImageDrawable(getResources().getDrawable(
				R.drawable.btn_tjdd));
		layout_top.setClickable(false);
		parent_arcmenu.setClickable(false);
	}

	/**
	 * 监听返回键
	 */
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			// hideSoftInputView();
			// if (chat_face_container.getVisibility() == View.VISIBLE) {
			// chat_face_container.setVisibility(View.GONE);
			// } else if (chat_add_container.getVisibility() == View.VISIBLE) {
			// chat_add_container.setVisibility(View.GONE);
			// } else {
			// finish();
			// }
			finish();
			return true;
		}
		return super.onKeyDown(keyCode, event);
	}

	/**
	 * 聊天记录刷新
	 */
	@Override
	public void onRefresh() {
		mListView.onRefreshCompleteHeader();

	}

	/**
	 * 设置显示内容,id为顺序Id
	 */
	public void onSetContent(int id, final View v) {
		try{
		ImageButton ib_kftel = ((ImageButton) include_service_wait
				.findViewById(R.id.ib_kftel));
		ib_kftel.setVisibility(View.VISIBLE);
		ib_kftel.setOnClickListener(this);
		int status = Integer.parseInt(list_order.get(id).getOrder_status());
		// 未处理和已入队，重新入队，改派，都归为，等待派车
		if (status == Value.ORDER_STATUS_UNTREATED
				|| status == Value.ORDER_STATUS_TEAM
				|| status == Value.ORDER_STATUS_RETEAM
				|| status == Value.ORDER_STATUS_GAIPAI
				|| status == Value.ORDER_STATUS_KF_GAIPAI) {
			// 关闭原本服务模式展开详情
			closeDetail();

			// 订单时间
			((TextView) v.findViewById(R.id.tv_time)).setText(DateFormat
					.onDateRemove_ss(list_order.get(id).getAppoint_time()));
			// 订单类型，拼车或者包车或者快件
			int type = Integer.parseInt(list_order.get(id).getOrder_type());
			String type_s = "";
			switch (type) {
			case Value.ORDER_TYPE_PC:
				type_s = getString(R.string.pc);
				// ((TextView) v.findViewById(R.id.tv_count)).setText(String
				// .format(getString(R.string.num), list_order.get(id)
				// .getOrderDetail().getCount()));
				break;
			case Value.ORDER_TYPE_BC:
				type_s = getString(R.string.bc);
				// ((TextView) v.findViewById(R.id.tv_count)).setText(String
				// .format(getString(R.string.num_car), list_order.get(id)
				// .getOrderDetail().getCount()));
				break;
			case Value.ORDER_TYPE_KJ:
				// ((TextView) v.findViewById(R.id.tv_count)).setText(String
				// .format(getString(R.string.num_jian), list_order
				// .get(id).getOrderDetail().getCount()));

				type_s = getString(R.string.kj);
				break;
			case Value.ORDER_TYPE_SN:
				// ((TextView) v.findViewById(R.id.tv_count))
				// .setVisibility(View.GONE);
				type_s = getString(R.string.sn);
				break;
			}
			// ((TextView) v.findViewById(R.id.tv_order_type)).setText(type_s);
			// 出发地
			((TextView) v.findViewById(R.id.tv_start)).setText(list_order
					.get(id).getOrderDetail().getStart().getAddress());
			// 目的地
			((TextView) v.findViewById(R.id.tv_end)).setText(list_order.get(id)
					.getOrderDetail().getEnd().getAddress());

			ImageView iv_own = (ImageView) v.findViewById(R.id.iv_own);
			// 判断自费类型
			try {
				if (Integer.parseInt(list_order.get(id).getOwn_expense()) == Value.NOOWN) {
					iv_own.setImageDrawable(context.getResources().getDrawable(
							R.drawable.icon_g));
				} else {
					iv_own.setImageDrawable(context.getResources().getDrawable(
							R.drawable.icon_z));
				}
			} catch (Exception e) {
			}
		}
		// 已指派和已上车，已下车，都归为，服务中
		else if (status == Value.ORDER_STATUS_ASSiIGN
				|| status == Value.ORDER_SIJI_CONFIRM
				|| status == Value.ORDER_STATUS_ONCAR
				|| status == Value.ORDER_STATUS_APPOINT) {
			((RatingBar) v.findViewById(R.id.rb_rating)).setRating(FormatUtil
					.onFormatStar((float) list_order.get(id).getDriver_star()));
			((TextView) v.findViewById(R.id.tv_rating)).setText(FormatUtil
					.onFormatStar((float) list_order.get(id).getDriver_star())
					+ "");
			layout_wait = ((RelativeLayout) v.findViewById(R.id.layout_detail));
			layout_wait.setVisibility(View.GONE);
			layout_service = ((LinearLayout) v
					.findViewById(R.id.layout_service));
			layout_service.setVisibility(View.VISIBLE);
			layout_service.setOnTouchListener(new OnTouchListener() {

				@Override
				public boolean onTouch(View v, MotionEvent event) {
					int move_y = 0;
					if (event.getAction() == MotionEvent.ACTION_DOWN) {
						down_y = (int) event.getY();
					}
					if (event.getAction() == MotionEvent.ACTION_UP) {
						move_y = (int) event.getY();
						if ((move_y - down_y) > 50) {
							if (!isOpenServiceWait || !isClick) {
							} else {
								if (include_service_wait.getVisibility() == View.GONE) {
									showDetail();
								}
							}
						} else if ((down_y - move_y) > 50) {
							if (!isOpenServiceWait || !isClick) {
							} else {
								if (include_service_wait.getVisibility() == View.VISIBLE) {
									closeDetail();
								}
							}
						}
					}
					return false;
				}
			});
			include_service_wait.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View arg0) {
					if (!isOpenServiceWait || !isClick)
						return;
					if (include_service_wait.getVisibility() == View.VISIBLE) {
//						closeDetail();
					}
				}
			});
			((TextView) v.findViewById(R.id.tv_driver_name)).setText(list_order
					.get(id).getDriver_name());
			((TextView) v.findViewById(R.id.tv_car_No)).setText(list_order.get(
					id).getCar_NO());
		}
		}catch(Exception e){}
	}

	/**
	 * 展开详情
	 */
	public void showDetail() {
		dots_top.setVisibility(View.GONE);
        new Handler().postDelayed(new Runnable() {
			
			@Override
			public void run() {
				setVisibility(include_service_wait, View.VISIBLE);
			}
		}, 200);
		mViewPager.setNoScroll(true);
		iv_ddxl.setVisibility(View.GONE);
	}

	/**
	 * 关闭详情
	 */
	public void closeDetail() {
		setVisibility(include_service_wait, View.GONE);
		mViewPager.setNoScroll(false);
		mHandler.postDelayed(new Runnable() {
			@Override
			public void run() {
				dots_top.setVisibility(View.VISIBLE);
				if (tv_title.getText().toString()
						.equals(getString(R.string.service_title))) {
					iv_ddxl.setVisibility(View.VISIBLE);
				} else {
					iv_ddxl.setVisibility(View.GONE);
				}

			}
		}, 800);
	}

	/**
	 * 显示标题状态
	 */
	public void onShowTitleStatus() {
		// 判断标题
		int status = Integer.parseInt(list_order.get(viewId).getOrder_status());
		if (status == Value.ORDER_STATUS_ONCAR) {
			setTitle(R.string.service_title);
		} else {
			if (status == Value.ORDER_STATUS_ASSiIGN
					|| status == Value.ORDER_SIJI_CONFIRM
					|| status == Value.ORDER_STATUS_APPOINT) {
				setTitle(true, getString(R.string.service_title), -1,
						getString(R.string.order_cancel));
			} else {
				setTitle(true, getString(R.string.wait_title), -1,
						getString(R.string.order_cancel));
			}
		}
	}

	/**
	 * 判断当前页面是否是服务状态。也是初始化一下地图数据，消息数据。
	 */
	public void isCurrentService(int ViewId) {
		/*--------设置服务中的等待--------------*/
		int status = Integer.parseInt(list_order.get(ViewId).getOrder_status());
		if (status == Value.ORDER_STATUS_UNTREATED
				|| status == Value.ORDER_STATUS_TEAM
				|| status == Value.ORDER_STATUS_RETEAM
				|| status == Value.ORDER_STATUS_GAIPAI
				|| status == Value.ORDER_STATUS_KF_GAIPAI) {
			iv_ddxl.setVisibility(View.GONE);
			setWaitCarMapLevel(ViewId);
			btn_cancel_order.setVisibility(View.GONE);
			// btn_change_order.setVisibility(View.VISIBLE);
			tv_estimat_time.setVisibility(View.VISIBLE);
			// 先隐藏在显示主要用于动画
			layout_estimat_time.setVisibility(View.GONE);
			layout_estimat_time.setVisibility(View.VISIBLE);
			long appoint = DateFormat.onDate_Long(list_order.get(viewId)
					.getAppoint_time());
			long time = DateFormat.getTime();
			long diff_time = appoint - time;
			if (diff_time < 1000 * 60 * estimat_time) {
				if (list_order.get(viewId).getAppoint_type()
						.equals(Value.TYPE_APPOINT + "")) {
					tv_estimat_time.setText(R.string.estimat_time2);
				} else {
					tv_estimat_time.setText(R.string.estimat_time3);
					if ((time - appoint) >= 1000 * 60 * 5) {
						tv_estimat_time.setText(R.string.estimat_time2);
					}
				}

			} else {
				// tv_estimat_time.setText(String.format(res
				// .getString(R.string.estimat_time), DateFormat
				// .onCNTimeRemove_yyss(appoint - 1000 * 60 * estimat_time)));
				tv_estimat_time.setText(String.format(
						res.getString(R.string.estimat_time), estimat_time));
			}
		} else if (status == Value.ORDER_STATUS_ASSiIGN
				|| status == Value.ORDER_SIJI_CONFIRM
				|| status == Value.ORDER_STATUS_ONCAR
				|| status == Value.ORDER_STATUS_APPOINT) {
			iv_ddxl.setVisibility(View.VISIBLE);
			setServiceCarMapLevel(status);
			if (list_order.get(viewId).getDriver_star() == 0) {
				MyStarTask.getInstance(context,
						list_order.get(viewId).getOrder_id(),
						list_order.get(viewId).getDriver_id())
						.setOnStarListener(this);
			}
			btn_cancel_order.setVisibility(View.GONE);
			if (status == Value.ORDER_STATUS_ONCAR) {
				btn_cancel_order.setVisibility(View.GONE);
				// btn_change_order.setVisibility(View.GONE);
			}
			tv_estimat_time.setVisibility(View.GONE);
			layout_estimat_time.setVisibility(View.GONE);
		}
		((ImageButton) include_service_wait.findViewById(R.id.ib_kftel))
				.setOnClickListener(this);
		((TextView) include_service_wait.findViewById(R.id.tv_time))
				.setText(DateFormat.onDateRemove_ss(list_order.get(ViewId)
						.getAppoint_time()));
		// 订单类型，拼车或者包车或者快件
		int type = Integer.parseInt(list_order.get(ViewId).getOrder_type());
		String type_s = "";
		// tv_price.setText(String.format(getString(R.string.service_price),
		// FormatUtil.onFormatPrice(Integer.parseInt(list_order.get(ViewId).getPrice())),
		// list_order.get(ViewId).getCoupon_sum()));
		tv_price.setText(context.getString(R.string.service_price));
		try {
			tv_total_price.setText(FormatUtil.onFormatPrice(Integer
					.parseInt(list_order.get(ViewId).getPrice())));
		} catch (Exception e) {
		}

		switch (type) {
		case Value.ORDER_TYPE_PC:
			type_s = getString(R.string.pc);

			// ((TextView) include_service_wait.findViewById(R.id.tv_count))
			// .setText(String.format(getString(R.string.num), list_order
			// .get(ViewId).getOrderDetail().getCount()));
			break;
		case Value.ORDER_TYPE_BC:
			type_s = getString(R.string.bc);
			//
			// ((TextView) include_service_wait.findViewById(R.id.tv_count))
			// .setText(String.format(getString(R.string.num_car),
			// list_order.get(ViewId).getOrderDetail().getCount()));
			break;
		case Value.ORDER_TYPE_KJ:

			// ((TextView) include_service_wait.findViewById(R.id.tv_count))
			// .setText(String.format(getString(R.string.num_jian),
			// list_order.get(ViewId).getOrderDetail().getCount()));
			type_s = getString(R.string.kj);
			break;
		case Value.ORDER_TYPE_SN:
			// ((TextView) include_service_wait.findViewById(R.id.tv_count))
			// .setVisibility(View.GONE);
			type_s = getString(R.string.sn);

			// tv_price.setText(getString(R.string.service_price2));
			// tv_total_price.setText(list_order.get(ViewId).getCoupon_sum() +
			// "");
			break;
		}
		// ((TextView) include_service_wait.findViewById(R.id.tv_order_type))
		// .setText(type_s);
		// 出发地

		((TextView) include_service_wait.findViewById(R.id.tv_start))
				.setText(list_order.get(ViewId).getOrderDetail().getStart()
						.getAddress());
		// 目的地
		((TextView) include_service_wait.findViewById(R.id.tv_end))
				.setText(list_order.get(ViewId).getOrderDetail().getEnd()
						.getAddress());

		ImageView iv_own = (ImageView) include_service_wait
				.findViewById(R.id.iv_own);
		// 判断自费类型
		try {
			if (Integer.parseInt(list_order.get(ViewId).getOwn_expense()) == Value.NOOWN) {
				iv_own.setImageDrawable(context.getResources().getDrawable(
						R.drawable.icon_g));
			} else {
				iv_own.setImageDrawable(context.getResources().getDrawable(
						R.drawable.icon_z));
			}
		} catch (Exception e) {
		}

		// 设置司机覆盖物
		if (mMarkerA != null) {
			mMarkerA.remove();
		}
		if (mMarker_start != null) {
			mMarker_start.remove();
		}
		if (mMarker_end != null) {
			mMarker_end.remove();
		}
		// 隐藏标注
		if (mBaiduMap != null)
			mBaiduMap.hideInfoWindow();
		mHandler.removeCallbacks(position_run);
		if (mBaiduMap != null)
			mBaiduMap.setMyLocationEnabled(true);
		if (status == Value.ORDER_STATUS_ASSiIGN
				|| status == Value.ORDER_SIJI_CONFIRM
				|| status == Value.ORDER_STATUS_ONCAR
				|| status == Value.ORDER_STATUS_APPOINT
				|| status == Value.ORDER_STATUS_OFFCAR) {
			// 已上车跟已下车不显示当前位置
			if (status != Value.ORDER_STATUS_ASSiIGN
					|| status == Value.ORDER_SIJI_CONFIRM) {
				if (mBaiduMap != null)
					mBaiduMap.setMyLocationEnabled(false);
			}
			sn_position_list.clear();
			getDriverLocation(list_order.get(ViewId).getDriver_id());
		} else {
			// 起始点
			LatLng ll_start = new LatLng(list_order.get(ViewId)
					.getOrderDetail().getStart().getLocation().getLat(),
					list_order.get(ViewId).getOrderDetail().getStart()
							.getLocation().getLng());
			OverlayOptions oo_start = new MarkerOptions().position(ll_start)
					.icon(bd_start).zIndex(9).draggable(true);
			if (mBaiduMap != null)
				mMarker_start = (Marker) (mBaiduMap.addOverlay(oo_start));
			// 终点
			LatLng ll_end = new LatLng(list_order.get(ViewId).getOrderDetail()
					.getEnd().getLocation().getLat(), list_order.get(ViewId)
					.getOrderDetail().getEnd().getLocation().getLng());
			OverlayOptions oo_end = new MarkerOptions().position(ll_end)
					.icon(bd_end).zIndex(9).draggable(true);
			if (mBaiduMap != null)
				mMarker_end = (Marker) (mBaiduMap.addOverlay(oo_end));
		}

		// 显示消息数据
		setChatMessage();

	}

	/**
	 * 设置等待派车地图等级
	 */
	public void setWaitCarMapLevel(int ViewId) {
		LatLng cenpt = new LatLng(mApplication.latitude, mApplication.longitude);
		MapStatus mMapStatus = new MapStatus.Builder().target(cenpt).build();
		MapStatusUpdate mMapStatusUpdate = MapStatusUpdateFactory
				.newMapStatus(mMapStatus);
		// 改变地图状态
		if (mBaiduMap != null)
			mBaiduMap.animateMapStatus(mMapStatusUpdate);
		LatLng p1LL = new LatLng(list_order.get(ViewId).getOrderDetail()
				.getStart().getLocation().getLat(), list_order.get(ViewId)
				.getOrderDetail().getStart().getLocation().getLng());
		LatLng p2LL = new LatLng(list_order.get(ViewId).getOrderDetail()
				.getEnd().getLocation().getLat(), list_order.get(ViewId)
				.getOrderDetail().getEnd().getLocation().getLng());
		;
		double distance = DistanceUtil.getDistance(p1LL, p2LL) / 1000;
		for (int i = 0; i < Map_Level.length; i++) {
			if ((i + 1) < Map_Level.length) {
				if (distance <= Map_Level[i] && distance >= Map_Level[i + 1]) {
					if (distance <= 90 && distance >= 45) {
						MapStatusUpdate u = MapStatusUpdateFactory.zoomTo(9);
						if (mBaiduMap != null)
							mBaiduMap.animateMapStatus(u);
						break;
					} else if (distance <= 45 && distance >= 20) {
						MapStatusUpdate u = MapStatusUpdateFactory.zoomTo(10);
						if (mBaiduMap != null)
							mBaiduMap.animateMapStatus(u);
						break;
					} else {
						MapStatusUpdate u = MapStatusUpdateFactory
								.zoomTo(i + 1);
						if (mBaiduMap != null)
							mBaiduMap.animateMapStatus(u);
						break;
					}
				}
			}
		}
	}

	/**
	 * 设置服务中的地图等级
	 */
	public void setServiceCarMapLevel(int status) {
		if (siLatLng != null) {
			LatLng cenpt;
			if (status == Value.ORDER_STATUS_ONCAR
					|| status == Value.ORDER_STATUS_APPOINT) {
				cenpt = siLatLng;
			} else {
				cenpt = new LatLng(mApplication.latitude,
						mApplication.longitude);
			}

			MapStatus mMapStatus = new MapStatus.Builder().target(cenpt)
					.build();
			MapStatusUpdate mMapStatusUpdate = MapStatusUpdateFactory
					.newMapStatus(mMapStatus);
			// 改变地图状态
			if (mBaiduMap != null)
				mBaiduMap.animateMapStatus(mMapStatusUpdate);
			LatLng myLL = new LatLng(cenpt.latitude, cenpt.longitude);
			double distance = DistanceUtil.getDistance(siLatLng, myLL) / 1000;
			for (int i = 0; i < Map_Level.length; i++) {
				if ((i + 1) < Map_Level.length) {
					if (distance <= Map_Level[i]
							&& distance >= Map_Level[i + 1]) {
						if (distance <= 90 && distance >= 45) {
							MapStatusUpdate u = MapStatusUpdateFactory
									.zoomTo(9);
							if (mBaiduMap != null)
								mBaiduMap.animateMapStatus(u);
							break;
						} else if (distance <= 45 && distance >= 20) {
							MapStatusUpdate u = MapStatusUpdateFactory
									.zoomTo(10);
							if (mBaiduMap != null)
								mBaiduMap.animateMapStatus(u);
							break;
						} else {
							MapStatusUpdate u = MapStatusUpdateFactory
									.zoomTo(i + 1);
							if (mBaiduMap != null)
								mBaiduMap.animateMapStatus(u);
							break;
						}
					}
				}
			}
		}
	}

	/**
	 * 设置聊天内容
	 */
	public void setChatMessage() {
		l_msg.clear();
		if (chatMessageListAdapter != null)
			chatMessageListAdapter.notifyDataSetChanged();
		if (map_jsmg.get(list_order.get(viewId).getOrder_id()) != null) {
			final ArrayList<Map<String, String>> list_jsmg = map_jsmg
					.get(list_order.get(viewId).getOrder_id());
			new AsyncTask<Void, Void, Void>() {

				@Override
				protected Void doInBackground(Void... arg0) {
					for (int i = 0; i < list_jsmg.size(); i++) {
						JSONObject jmsg = null;
						JSONObject jmsg_data = null;
						Msgs.Data msgs_data = null;
						try {
							jmsg = new JSONObject(list_jsmg.get(i).get(
									DBcolumns.MESSAGE_JSON));
							jmsg_data = new JSONObject(
									jmsg.getString(GMsg.msg_data));
							msgs_data = (Msgs.Data) new JsonBuild().getData(
									Msgs.Data.class, jmsg_data.toString());
						} catch (Exception e) {
						}

						int message_type = Integer.parseInt(list_jsmg.get(i)
								.get(DBcolumns.MESSAGE_TYPE));
						ChatMessage cm = new ChatMessage();
						switch (message_type) {
						case GMsg.OFFICAIL_ONLINE_PAIDAN:
							if (msgs_data != null) {
								cm.chatMsg = String.format(res
										.getString(R.string.order_paidan_msg),
										msgs_data.getDriver_name(), msgs_data
												.getCar_NO());
								cm.nickName = "nickName_I";
								cm.userID = YOU_ID;
								cm.time = list_jsmg.get(i).get(
										DBcolumns.MESSAGE_TIME);
								l_msg.add(cm);
							}
							break;
						case GMsg.OFFICAIL_ONLINE_ONCAR:
							if (msgs_data != null) {
								cm.chatMsg = String.format(
										res.getString(R.string.msg_oncar),
										msgs_data.getReason());
								cm.nickName = "nickName_I";
								cm.userID = YOU_ID;
								cm.time = list_jsmg.get(i).get(
										DBcolumns.MESSAGE_TIME);
								l_msg.add(cm);
							}
							break;
						case GMsg.OFFICAIL_ONLINE_CANCEL:
						case GMsg.ONLINE_KF_CANCEL:
							if (msgs_data != null) {
								cm.chatMsg = res
										.getString(R.string.order_cancel_msg);
								cm.nickName = "nickName_I";
								cm.userID = YOU_ID;
								cm.time = list_jsmg.get(i).get(
										DBcolumns.MESSAGE_TIME);
								l_msg.add(cm);
							}
							break;
						case GMsg.OFFICAIL_ONLINE_GAIPAI:
						case GMsg.ONLINE_KF_GAIPAIL:
							if (msgs_data != null) {
								cm.chatMsg = String.format(res
										.getString(R.string.order_gaipai_msg),
										msgs_data.getReason());
								cm.nickName = "nickName_I";
								cm.userID = YOU_ID;
								cm.time = list_jsmg.get(i).get(
										DBcolumns.MESSAGE_TIME);
								l_msg.add(cm);
							}
							break;
						case GMsg.ONLINE_RELOGIN:
							break;
						case GMsg.ONLINE_BUSY:
							if (msgs_data != null) {
								cm.chatMsg = msgs_data.getText();
								cm.nickName = "nickName_I";
								cm.userID = YOU_ID;
								cm.time = list_jsmg.get(i).get(
										DBcolumns.MESSAGE_TIME);
								l_msg.add(cm);
							}
							break;
						case GMsg.ONLINE_XIADAN:
						case GMsg.ONLINE_BG_ORDER:
							long appoint = DateFormat.onDate_Long(list_order
									.get(viewId).getAppoint_time());
							long time = DateFormat.getTime();
							long diff_time = appoint - time;
							if (diff_time < 1000 * 60 * estimat_time) {
								cm.chatMsg = res
										.getString(R.string.order_quickly_msg);
							} else {
								cm.chatMsg = res
										.getString(R.string.order_quickly_msg);
								// cm.chatMsg = String
								// .format(res
								// .getString(R.string.order_quickly2_msg),
								// DateFormat
								// .onCNTimeRemove_yyss(appoint - 1000 * 60 *
								// estimat_time));
							}

							cm.nickName = "nickName_I";
							cm.userID = YOU_ID;
							cm.time = list_jsmg.get(i).get(
									DBcolumns.MESSAGE_TIME);
							l_msg.add(cm);
							break;
						case ONLINE_CHAT:// 为自己发的,订单闲情
							int id = Integer.parseInt(list_jsmg.get(i).get(
									MSG_USER));
							sendMsgText(list_jsmg.get(i).get(MSG_CONTENT), id,
									list_jsmg.get(i)
											.get(DBcolumns.MESSAGE_TIME));
						default:
							break;
						}
					}
					return null;
				}

				@Override
				protected void onPostExecute(Void result) {
					if (null == chatMessageListAdapter) {
						chatMessageListAdapter = new ChatMessageListAdapter(
								l_msg, context);
						mListView.setAdapter(chatMessageListAdapter);
					} else {
						chatMessageListAdapter.setL(l_msg);
						chatMessageListAdapter.notifyDataSetChanged();
					}
					mListView.setSelection(mListView.getBottom());
					super.onPostExecute(result);
				}

			}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);

		}
	}

	/**
	 * 获取司机位置
	 */
	public void getDriverLocation(String driver_id) {
		if (driver_id == null || driver_id.equals("")) {
			return;
		}
		if (list_order.size() == 0)
			return;
		LogUtils.e("position", "开始获取地理位置" + driver_id);
		JSONObject jsonObject = null;
		try {
			jsonObject = new JSONObject();
			jsonObject.put("command", 4);
			// jsonObject.put("line_id", list_order.get(viewId).getLine_id());
			jsonObject.put("line_id", list_order.get(viewId).getTcId());
			jsonObject.put("uid", driver_id);

		} catch (JSONException e) {
			e.printStackTrace();
		}
		String sn_position_string = MyMesssage.sn_position + "_"
				+ (new Date().getTime());
		sn_position_list.add(sn_position_string);
		// 获取地理位置
		SDK.ins.mClient.request(mApplication.getUid(), sn_position_string, 30,
				jsonObject.toString());
		position_run.setDriver_Id(driver_id);
		mHandler.postDelayed(position_run, 1000 * 5);

	}

	/**
	 * 设置中心点位置
	 */
	public void setCenterPoint(double lat, double lng, final int zoom) {
		int status = Integer.parseInt(list_order.get(viewId).getOrder_status());
		LatLng cenpt;
		if ((status == Value.ORDER_STATUS_ONCAR || status == Value.ORDER_STATUS_APPOINT)
				&& siLatLng != null) {
			cenpt = siLatLng;
		} else {
			cenpt = new LatLng(lat, lng);
		}
		MapStatus mMapStatus = new MapStatus.Builder().target(cenpt).build();
		MapStatusUpdate mMapStatusUpdate = MapStatusUpdateFactory
				.newMapStatus(mMapStatus);
		if (mBaiduMap != null)
			mBaiduMap.animateMapStatus(mMapStatusUpdate);
		new Handler().postDelayed(new Runnable() {

			@Override
			public void run() {
				MapStatusUpdate u = MapStatusUpdateFactory.zoomTo(zoom);
				if (mBaiduMap != null)
					mBaiduMap.animateMapStatus(u);
			}
		}, 500);

	}

	/**
	 * 获取根据Id获取消息数据库
	 */
	public ArrayList<Map<String, String>> onRead_jsmg(String order_id) {
		ArrayList<Map<String, String>> list = new ArrayList<Map<String, String>>();
		Cursor c = db_jmsg.onQuery(order_id);
		c.moveToFirst();
		if (c.getCount() > 0) {
			do {
				Map<String, String> map = new HashMap<String, String>();
				for (int i = 0; i < c.getColumnCount(); i++) {
					map.put(c.getColumnName(i), c.getString(i));
				}
				list.add(map);
			} while (c.moveToNext());
		}
		c.close();
		db_jmsg.onColse();
		return list;
	}

	@Override
	protected void onDestroy() {
		if (mInitTask != null
				&& mInitTask.getStatus() != AsyncTask.Status.FINISHED)
			mInitTask.cancel(true);
		mHandler.removeCallbacks(position_run);
		super.onDestroy();
	}

	protected void onPause() {
		super.onPause();
	}

	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		if (requestCode == this.requestCode) {
			if (data != null) {
				int size = list_order.size();
				list_order.clear();
				ArrayList<OfficialOrderList> list = db_myordering.onReadDB_ing(
						this, MyOrderActivity.num_ing, true);
				if (list != null) {
					list_order.addAll(list);
				}
				if (size != list_order.size()) {
					viewId = 0;
				}
				if (list_order.size() == 0)
					finish();
				else {
					initPage();
					onShowTitleStatus();
				}
			}
		}
		super.onActivityResult(requestCode, resultCode, data);
	}

	@Override
	public void finish() {
		if (type_activity == 1) {
			Intent intent = new Intent();
			setResult(resultCode, intent);
		} else if (type_activity == 0) {
			Intent intent = new Intent();
			setResult(resultCode, intent);
		}
		super.finish();
	}

	@Override
	public void onNotify(int type, JSONObject jb, Msgs.Data msgs_data) {
		/** 是否继续执行父类 */
		boolean isContinue = true;
		String order_id = null;
		switch (type) {
		case GMsg.OFFICAIL_ONLINE_PAIDAN:
		case GMsg.OFFICAIL_ONLINE_GAIPAI:
		case GMsg.ONLINE_KF_GAIPAIL:
		case GMsg.OFFICAIL_ONLINE_ONCAR:
		case GMsg.OFFICAIL_ONLINE_ARRIVE:
			if (type == GMsg.OFFICAIL_ONLINE_ONCAR
					|| type == GMsg.OFFICAIL_ONLINE_ARRIVE) {
				MapStatusUpdate u = MapStatusUpdateFactory.zoomTo(15);
				if (mBaiduMap != null)
					mBaiduMap.animateMapStatus(u);
			}
			order_id = msgs_data.getOrder_id();
			list_order.clear();
			list_order.addAll(db_myordering.onReadDB_ing(this,
					MyOrderActivity.num_ing, true));
			// 根据订单Id存储顺序id
			for (int i = 0; i < list_order.size(); i++) {
				map_id.put(list_order.get(i).getOrder_id(), i);
			}
			if (order_id != null) {
				try {
					viewId = map_id.get(order_id);
				} catch (Exception e) {
					ToastUtil.showToast(context, R.string.order_change_refresh);
					finish();
				}

			}

			initPage();
			onShowTitleStatus();
			break;
		case GMsg.ONLINE_UNPROCESSED_RESULT:
			isContinue = false;
			MyOrderTask.getInstance(context, MyOrderActivity.num_ing,
					Value.TYPE_ING, Value.OWNALL, MyOrderTask.TYPE_REFRESH)
					.setOnOrderFinishListener(this);
			break;
		case GMsg.ONLINE_KF_CHANGE:
			isContinue = false;
			ToastUtil.showToast(context, R.string.toast_change);
			MyOrderTask.getInstance(context, MyOrderActivity.num_ing,
					Value.TYPE_ING, Value.OWNALL, MyOrderTask.TYPE_REFRESH)
					.setOnOrderFinishListener(this);
			break;
		case GMsg.OFFICAIL_ONLINE_ROUND_TRIP:
			isContinue = false;
			MessageDialog.onRoundTripDialog(context, msgs_data, true);
			order_id = msgs_data.getOrder_id();
			list_order.clear();
			list_order.addAll(db_myordering.onReadDB_ing(this,
					MyOrderActivity.num_ing, true));
			// 根据订单Id存储顺序id
			for (int i = 0; i < list_order.size(); i++) {
				map_id.put(list_order.get(i).getOrder_id(), i);
			}
			if (order_id != null) {
				try {
					viewId = map_id.get(order_id);
				} catch (Exception e) {
					ToastUtil.showToast(context, R.string.order_change_refresh);
					finish();
				}

			}

			initPage();
			onShowTitleStatus();
			break;
		case GMsg.OFFICAIL_ONLINE_CANCEL:
		case GMsg.ONLINE_KF_CANCEL:
			isContinue = false;
			try {
				JSONObject json_jmsg = jb.getJSONObject(GMsg.msg_jmsg);
				JSONObject json_data = new JSONObject(
						json_jmsg.getString(GMsg.msg_data));
				order_id = json_data.getString(GMsg.msg_order_id);
			} catch (JSONException e1) {
				// 出错了,该类型不是在线是离线
				try {
					JSONObject json_jmsg = jb.getJSONObject(GMsg.msg_jmsg);
					JSONArray msgs = json_jmsg.getJSONArray(GMsg.msg_msgs);
					if (msgs != null && msgs.length() >= 1) {
						JSONObject jo = new JSONObject(msgs.get(0).toString());
						JSONObject json_data = null;
						json_data = new JSONObject(jo.getString(GMsg.msg_data));
						order_id = json_data.getString(GMsg.msg_order_id);
					}
				} catch (Exception e) {
				}
			}
			if (order_id != null) {
				Intent intent = new Intent(context, OrderCancelReason.class);
				intent.putExtra(OrderMsg.extra_order_id, order_id);
				startActivityForResult(intent, requestCode);
			}
			break;
		case GMsg.OFFICAIL_ONLINE_OFFCAR:
			isContinue = false;
			try {
				JSONObject json_jmsg = jb.getJSONObject(GMsg.msg_jmsg);
				JSONObject json_data = new JSONObject(
						json_jmsg.getString(GMsg.msg_data));
				order_id = json_data.getString(GMsg.msg_order_id);
			} catch (JSONException e1) {
				// 出错了,该类型不是在线是离线
				try {
					JSONObject json_jmsg = jb.getJSONObject(GMsg.msg_jmsg);
					JSONArray msgs = json_jmsg.getJSONArray(GMsg.msg_msgs);
					if (msgs != null && msgs.length() >= 1) {
						JSONObject jo = new JSONObject(msgs.get(0).toString());
						JSONObject json_data = null;
						json_data = new JSONObject(jo.getString(GMsg.msg_data));
						order_id = json_data.getString(GMsg.msg_order_id);
					}
				} catch (Exception e) {
				}
			}
			if (order_id != null) {
				Intent intent = new Intent(context,
						OrderEvaluationActivity2.class);
				intent.putExtra(OrderMsg.order_id_finish, order_id);
				intent.putExtra(OrderMsg.finish_type, OrderMsg.finish_ing);
				startActivityForResult(intent, requestCode);
			}
			break;
		case GMsg.ONLINE_POSITION:
			String sn_position = "";
			try {
				sn_position = jb.getString("sn");
			} catch (JSONException e1) {
			}
			if (sn_position_list.contains(sn_position))
				;
			LogUtils.e("position", "开始显示司机位置");
			try {
				String jsmg_string = jb.getString(GMsg.msg_jmsg);
				JSONObject jmsg_data = new JSONObject(jsmg_string);
				String position_string = jmsg_data.getString(GMsg.msg_position);
				Position position = (Position) new JsonBuild().getData(
						Position.class, position_string);
				// 设置司机覆盖物
				if (mMarkerA != null) {
					mMarkerA.remove();
				}
				// 经纬度等于0
				if (position.getLocation().getLat() == 0
						|| position.getLocation().getLng() == 0) {
					return;
				}
				siLatLng = new LatLng(position.getLocation().getLat(), position
						.getLocation().getLng());
				LatLng cenpt = new LatLng(mApplication.latitude,
						mApplication.longitude);

				OverlayOptions ooA = new MarkerOptions().position(siLatLng)
						.icon(bdA).draggable(true);
				if (mBaiduMap != null)
					mMarkerA = (Marker) (mBaiduMap.addOverlay(ooA));
				// 已指派
				int status = Integer.parseInt(list_order.get(viewId)
						.getOrder_status());
				if (status == Value.ORDER_STATUS_ASSiIGN
						|| status == Value.ORDER_SIJI_CONFIRM) {
					int distance_about;
					double distance = DistanceUtil.getDistance(siLatLng, cenpt) / 1000;
					LayoutInflater inflater = LayoutInflater.from(context);
					View distance_view = (View) inflater.inflate(
							R.layout.map_distance, null);
					TextView tv_distance = (TextView) distance_view
							.findViewById(R.id.tv_distance);
					if (distance >= 1) {
						distance_about = (int) Math.round(distance);
						tv_distance
								.setText(Html
										.fromHtml("<font color=\"#169bdb\">"
												+ distance_about
												+ "</font><font color=\"#6a6d71\">公里</font>"));
					} else {
						DecimalFormat df = new DecimalFormat("#.000");
						distance_about = Integer.parseInt(df.format(distance)
								.replace("0.", "").replace(".", ""));
						tv_distance
								.setText(Html
										.fromHtml("<font color=\"#169bdb\">"
												+ distance_about
												+ "</font><font color=\"#6a6d71\">米</font>"));
					}

					mInfoWindow = new InfoWindow(distance_view, siLatLng, -50);
					if (mBaiduMap != null)
						mBaiduMap.showInfoWindow(mInfoWindow);

				} else if (Integer.parseInt(list_order.get(viewId)
						.getOrder_status()) == Value.ORDER_STATUS_APPOINT) {
					// 有值就直接显示已达到
					setAppointPosition(Online.map_price.get(list_order.get(
							viewId).getOrder_id()), siLatLng);
				}
				// 已上车
				else if (Integer.parseInt(list_order.get(viewId)
						.getOrder_status()) == Value.ORDER_STATUS_ONCAR) {

					setMapPrice(Online.map_price.get(list_order.get(viewId)
							.getOrder_id()), siLatLng);
				}
			} catch (Exception e) {
			}
			break;
		}
		if (isContinue) {
			super.onNotify(type, jb, msgs_data);
		}
	}

	/**
	 * 设置到达指定位置
	 */
	public void setAppointPosition(String jmsg_data, LatLng ll) {
		try {
			Msgs.Data msgs_data = (Msgs.Data) new JsonBuild().getData(
					Msgs.Data.class, jmsg_data);
			String msg_order_id = msgs_data.getOrder_id();
			if (msg_order_id.equals(list_order.get(viewId).getOrder_id())) {
				LayoutInflater inflater = LayoutInflater.from(context);
				View price_view = (View) inflater.inflate(R.layout.map_appoint,
						null);
				TextView tv_time = (TextView) price_view
						.findViewById(R.id.tv_time);
				TextView tv_wait = (TextView) price_view
						.findViewById(R.id.tv_wait);
				tv_time.setText(DateFormat.onCNTimeRemove_hhmm(Long
						.parseLong(msgs_data.getPriceDetail().getTimerStart())));
				long timerStart = Long.parseLong(msgs_data.getPriceDetail()
						.getTimerStart());
				long currenttime = DateFormat.onMConverS(DateFormat.getTime());
				tv_wait.setText(((currenttime - timerStart) / 60) + "");
				mInfoWindow_price = new InfoWindow(price_view, ll, -50);
				if (mBaiduMap != null)
					mBaiduMap.showInfoWindow(mInfoWindow_price);
			} else {
				if (mBaiduMap != null)
					mBaiduMap.hideInfoWindow();
				setCenterPoint(ll.latitude, ll.longitude, 13);
			}
		} catch (Exception e) {
		}
	}

	/**
	 * 显示里程费跟时长费
	 */
	public void setMapPrice(String jmsg_data, LatLng ll) {
		boolean isShow = false;
		VehicleInfo mVehicleInfo = null;
		try {
			mVehicleInfo = list_order.get(viewId).getVehicleDetail()
					.getVehicleInfo();
		} catch (Exception e) {
		}
		if (mVehicleInfo != null) {
			int paidan_type = mVehicleInfo.getVtype();
			if (paidan_type == Value.taxi_vtype) {
				isShow = false;
			} else {
				isShow = true;
			}
		} else {
			isShow = true;
		}
		if (isShow) {
			try {
				Msgs.Data msgs_data = (Msgs.Data) new JsonBuild().getData(
						Msgs.Data.class, jmsg_data);
				String msg_order_id = msgs_data.getOrder_id();
				if (msg_order_id.equals(list_order.get(viewId).getOrder_id())) {
					LayoutInflater inflater = LayoutInflater.from(context);
					View price_view = (View) inflater.inflate(
							R.layout.map_price, null);
					TextView tv_mileage_price = (TextView) price_view
							.findViewById(R.id.tv_mileage_price);
					TextView tv_time_price = (TextView) price_view
							.findViewById(R.id.tv_time_price);
					TextView tv_total_price = (TextView) price_view
							.findViewById(R.id.tv_total_price);
					tv_mileage_price.setText(String.format(
							getString(R.string.mileage_price), FormatUtil
									.onFormatDistance(msgs_data
											.getPriceDetail().getDistance()),
							FormatUtil.onFormatPrice2(msgs_data
									.getPriceDetail().getDistanceprice())));
                     int owner_type=0;
                     try{owner_type=Integer.parseInt(msgs_data.getPriceDetail().getOwner_type());}catch(Exception e){}
                     //如果是泉州公务车的且是车型是委托的，则走低俗行驶
					if(VersionUtils.getVersionType(context)==VersionType.official_qz&&owner_type==1){
						long wait_minutes = (long) Math.floor(Double.parseDouble(msgs_data.getPriceDetail()
								.getWaitMinutes()));
						tv_time_price.setText(String.format(
								getString(R.string.time_price),
								(wait_minutes), FormatUtil
										.onFormatPrice2(msgs_data.getPriceDetail()
												.getTimeprice())));
					}else{
						long timerStart = Long.parseLong(msgs_data.getPriceDetail()
								.getTimerStart());
						long currenttime = DateFormat.onMConverS(DateFormat
								.getTime());
						tv_time_price.setText(String.format(
								getString(R.string.time_price),
								(currenttime - timerStart) / 60, FormatUtil
										.onFormatPrice2(msgs_data.getPriceDetail()
												.getTimeprice())));
					}
					tv_total_price.setText(FormatUtil.onFormatPrice2(msgs_data
							.getPriceDetail().getTotalprice()));
					mInfoWindow_price = new InfoWindow(price_view, ll, -50);
					if (mBaiduMap != null)
						mBaiduMap.showInfoWindow(mInfoWindow_price);
				} else {
					if (mBaiduMap != null)
						mBaiduMap.hideInfoWindow();
					setCenterPoint(ll.latitude, ll.longitude, 13);
				}
			} catch (Exception e) {
			}
		}
	}

	public class MyPosition_Run implements Runnable {
		private String driver_id;

		public void setDriver_Id(String driver_id) {
			this.driver_id = driver_id;
		}

		@Override
		public void run() {
			getDriverLocation(driver_id);
		}

	}

	@Override
	public void startActivityForResult(Intent intent, int code) {
		mHandler.removeCallbacks(position_run);
		super.startActivityForResult(intent, code);
	}

	public void onOrderFinish(int status, int flag, int own_expense,
			ArrayList<OfficialOrderList> list) {
		if (loaddialog != null) {
			loaddialog.dismiss();
		}
		if(flag==Value.TYPE_ING){
		int size = list_order.size();
		list_order.clear();
		if (list != null) {
			// 过滤掉待支付
			for (int i = 0; i < list.size(); i++) {
				if (Integer.parseInt(list.get(i).getOrder_status()) < Value.ORDER_STATUS_OFFCAR) {
					list_order.add(list.get(i));
				}
			}
			if (size != list_order.size()) {
				viewId = 0;
			}
			if (list_order.size() == 0)
				finish();
			else {
				initPage();
				onShowTitleStatus();
				initMap();
			 }
	      }
		}
	}

	/**
	 * 取消订单
	 */
	public void onCancel() {
		String start_city = ToCity.getCity(list_order.get(viewId)
				.getOrderDetail().getStart().getAddress());

		String end_city = ToCity.getCity(list_order.get(viewId)
				.getOrderDetail().getEnd().getAddress());
		dialog.setTitle(getString(R.string.mydailog_title));
		// dialog.setContent(String.format(
		// getString(R.string.mydailog_content_cancel_order2),
		// DateFormat.onDateRemove_mmss(list_order.get(viewId)
		// .getAppoint_time()), start_city, end_city));
		dialog.setContent(getString(R.string.mydailog_content_cancel_order2));
		dialog.setLeftButtonText(getString(R.string.mydailog_giveup_cancel));
		dialog.setRightButtonText(getString(R.string.mydailog_confirm_cancel));
		if (dialog != null && !dialog.isShowing()) {
			dialog.show();
		}
		dialog.setOnClickLeftListener(new onClickLeftListener() {
			@Override
			public void onClickLeft() {
				dialog.dismiss();
			}
		});
		dialog.setOnClickRightListener(new onClickRightListener() {

			@Override
			public void onClickRight() {
				dialog.dismiss();
				MyCancelOrderTask.getInstance(context,
						list_order.get(viewId).getOrder_id(),
						"0", 0)
						.setOnCancelOrderListener(StartServiceActivity.this);
			}
		});
	}

	@Override
	public void onCancelPrice(int status, final int price) {
		if (status == MyCancelPriceTask.STATUS_SUCCESS) {
			onCancelPrice(price);
		} else {
			ToastUtil.showToast(context, R.string.no_network);
		}

	}

	/**
	 * 消单费
	 */
	public void onCancelPrice(final int price) {
		final MyAlertDailog dialog = new MyAlertDailog(context);
		dialog.setTitle("是否取消订单？");
		if (price != 0) {
			dialog.setContent2(String.format(
					res.getString(R.string.mydailog_cancel_price),
					FormatUtil.onFormatPrice(price)));
		} else {
			dialog.setContent2(res.getString(R.string.mydailog_cancel_price2));
		}
		dialog.setLeftButtonText(res.getString(R.string.mydailog_giveup_cancel));
		dialog.setRightButtonText(res
				.getString(R.string.mydailog_confirm_cancel));
		if (dialog != null && !dialog.isShowing()) {
			dialog.show();
		}
		dialog.setOnClickLeftListener(new onClickLeftListener() {
			@Override
			public void onClickLeft() {
			}
		});
		dialog.setOnClickRightListener(new onClickRightListener() {

			@Override
			public void onClickRight() {
				MyCancelOrderTask
						.getInstance(context,
								list_order.get(viewId).getOrder_id(),
								price + "", price).setOnCancelOrderListener(
								StartServiceActivity.this);
			}
		});
	}

	@Override
	public void onCancelOrder(int status) {
		if (status == MyCancelOrderTask.STATUS_SUCCESS) {
			// TODO Auto-generated method stub
			ToastUtil.showToast(context, R.string.cancel_success);
			db_myordering.onUpdate(list_order.get(viewId).getOrder_id(),
					Value.ORDER_STATUS_CANCEL);
			db_myorder.onUpdate(list_order.get(viewId).getOrder_id(),
					Value.ORDER_STATUS_CANCEL);
			Intent intent = new Intent(context, OrderCancelReason.class);
			intent.putExtra(OrderMsg.extra_order_id, list_order.get(viewId)
					.getOrder_id());
			startActivityForResult(intent, requestCode);
		} else {
			ToastUtil.showToast(context, R.string.no_network);
		}
	}

	@Override
	public void onStarFinish(String order_id, int star) {
		if (list_order.get(viewId).getOrder_id().equals(order_id)) {
			View v = list_view.get(viewId);
			((RatingBar) v.findViewById(R.id.rb_rating)).setRating(FormatUtil
					.onFormatStar((float) star));
			((TextView) v.findViewById(R.id.tv_rating)).setText(FormatUtil
					.onFormatStar((float) star) + "");
		}
		for (int i = 0; i < list_order.size(); i++) {
			if (order_id.equals(list_order.get(i).getOrder_id())) {
				list_order.get(i).setDriver_star(star);
			}
		}
	}
}
